home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!gibson
- From: gibson@netcom.com (Bob Gibson)
- Subject: Re: Q: implicit converstion - error?
- Message-ID: <gibsonDLyI11.Mo2@netcom.com>
- Organization: A number of persons or groups united for some purpose
- X-Newsreader: TIN [version 1.2 PL1]
- References: <gibsonDLr0rs.AEB@netcom.com> <310cc2a1.11393601@news.compuserve.com>
- Date: Mon, 29 Jan 1996 18:58:13 GMT
- Sender: gibson@netcom21.netcom.com
-
- John Bain (johnb@pivotal-dm.ccmail.compuserve.com) wrote:
- ...
- : Conversion from char** -> const char ** is not
- : allowed, because it is potentially unsafe. Consider
- : the following code:
- :
- : --------------------------------------------------
- :
- : const char c_ch;
- :
- : const char **pp_c_ch;
- : char *p_ch;
- :
- : pp_c_ch = &p_ch; // OK _if_ char** -> const char ** allowed
- : *pp_c_ch = &c_ch; // allowed - assigning &<const char> to const char*
- : // p_ch now points at c_ch
- : *p_ch = 'X'; // OOPS, modified c_ch!
- :
- : ---------------------------------------------------
-
- I don't see where your example explains the problem I described. The
- fact that the calling function considers the thing as a "* * char" is
- only relavent is we are using shared memory/multi-threading.
-
- If I say that I want to consider a character to which I have an address
- as constant, this indicates that I promise not to change it. The fact
- that you can/will change it when I return to you doesn't matter to me.
- The fact that it may change outside of the function would only be of
- concern to the optimizer (and I guess the user would then identifiy it
- as volatile).
-
- I don't see why the compilers are complaining...
-
- Bob
- --
- O.J. Verdict - The best innocence money can buy
-
- Bob Gibson -- gibson@netcom.com
-